﻿#ifndef WIDGETROIDRAW_H
#define WIDGETROIDRAW_H

#include <QWidget>
#include <QButtonGroup>
#include <QPushButton>
#include <QToolButton>
#include <QComboBox>
#include "ItemBase.h"
#include "GraphicsView.h"


enum RoiWorkMode{
    RWM_Normal = 0,
    RWM_ModelMatch,
    RWM_CircleFind,
    RWM_LineFind,
};

class WidgetRoiDraw : public QWidget
{
    Q_OBJECT
public:
    explicit WidgetRoiDraw(QWidget *parent = nullptr);
    void setImage(QImage img);
    GraphicsView* getView(){return mView;}
    void setMode(RoiWorkMode mode);
    void setItem(ItemBase* item);
    ItemBase* getItem(){return mItem;}
    void setMode();

signals:
    void sigDrawFinish(ItemBase* item);
    void sigRemoveOne(ItemBase* item);
    void sigItemSelectChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason);
    void sigRemoveAll();
protected:
    virtual void keyPressEvent(QKeyEvent* event) override;
private:
    void setupUi();
    void initConnection();
    void onShapeButtonClicked(const int& id);
    void drawStart();
    void onCreateFinished();
public:
    static QMap<DefineItemType,QString> mapShapeIconPath;
private:
    ItemBase* mItem = nullptr;
    QImage mImg;
    bool isDraw = false;
private:
    GraphicsView* mView;
    QButtonGroup* btngrpShape;
    QComboBox* cbboxDrawMethod;
    QPushButton* pbtnOpenImage;
    QPushButton* pbtnRemove;
    QPushButton* pbtnClear;

};

#endif // WIDGETROIDRAW_H
